import time
from zentao_pms.base.base_get import Tools


class ccs_tools(Tools):
    ccs_url = "http://192.168.0.125:7007/www/index.php?m=user&f=login&referer=L3d3dy8="
    organization = '[id = "menucompany"]'
    sskuang = '[id="value4"]'  # 定位搜索框
    ss_button = '[id="submit"]'  # 定位搜索按钮
    cz_button = '[onclick="resetForm(this)"]'  # 定位重置按钮
    sc_button = '[class="btn-icon iframe"]'  # 定位删除按钮
    sr_yzmm = '[type="password"]'  # 输入密码定位
    qrsc_button = '[class="w-100px"] button'  # 定位确认删除按钮
    ccs_success_ele = '[class="pager"]'  # 断言  暂时没有记录
    ifram = '[id = "modalIframe"]'  # 切换表单

    def ccs_action(self, usern, admin_word):
        self.visit(self.ccs_url)
        self.by_css(self.organization).click()
        time.sleep(1)
        self.by_css(self.sskuang).send_keys(usern)
        time.sleep(1)
        self.by_css(self.ss_button).click()
        time.sleep(2)
        self.by_css(self.cz_button).click()
        time.sleep(2)

        self.by_css(self.sskuang).send_keys(usern)
        time.sleep(1)
        self.by_css(self.ss_button).click()
        time.sleep(1)

        self.by_css(self.sc_button).click()
        time.sleep(1)

        self.switch(self.ifram)

        # self.by_css(self.ifram)
        # time.sleep(1)
        #
        # Test_ccs.test_css_success(self.by_css(self.ifram))
        # time.sleep(1)

        self.by_css(self.sr_yzmm).send_keys(admin_word)
        time.sleep(1)
        self.by_css(self.qrsc_button).click()
        time.sleep(1)

        self.switch_to()

    def get_success_msg(self):
        return self.by_css(self.ccs_success_ele).text